# -*- coding: utf-8 -*-
"""
@version: 1.0
@author: Pyma
@file: decorators
@time: 2019/11/23 21:14
"""

from utils import restful
from django.shortcuts import redirect

def xfz_login_required(func):
    def wrapper(request, *args, **kwargs):
        if request.user.is_authenticated:
            return func(request, *args, **kwargs)
        else:
            if request.is_ajax():
                return restful.unauth(message="请先登入")
            else:
                return redirect("/")
    return wrapper
